Update _client.py to fix bug when proxy_map contains None #3517
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When proxy_map contains None as value, the library will throw an exception, the proposed changes will fix the error:
proxy_map:
{'http://': Proxy('http://sys-proxy-rd-relay.xxxx.org:8119'), 'https://': Proxy('http://sys-proxy-rd-relay.xxxx.org:8119'), 'all://localhost': None}
Exception:
File /usr/local/lib/python3.11/dist-packages/httpx/_urlparse.py:411, in normalize_port(port, scheme) 409 port_as_int = int(port)
410 except ValueError:
--> 411 raise InvalidURL(f"Invalid port: {port!r}") 413 # See https://url.spec.whatwg.org/#url-miscellaneous 414 default_port = {"ftp": 21, "http": 80, "https": 443, "ws": 80, "wss": 443}.get( 415 scheme
416 )
InvalidURL: Invalid port: ':'
Summary
Checklist